<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="<%=commonPath%>/pageRc/layui/css/layui.css"
	media="all">
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/layui/layui.js"></script>
		<script type="text/javascript"
	src="<%=commonPath %>/pageRc/My97DatePicker/WdatePicker.js"></script>

<title>目标管理</title>
<style>
.Wdate {
    border: #efefef 1px solid;
    height: 35px;
    width: 190px;
    background: #ffffff url(datePicker.gif) no-repeat right;
}
</style>
<script>
	$(function(){

 	})
	//注意：选项卡 依赖 element 模块，否则无法进行工能性操作
	layui.use('element', function() {
		var element = layui.element();

		//…
	});
	$(document).ready(function(){
		$("#datePicker1").empty().html('<input type="text" id="months" name="months" class="Wdate" onClick="WdatePicker({months:\'%y-%M\',dateFmt:\'yyyy\'})"/>');
});
	
</script>
<jsp:include page="publicMethod.jsp" />
</head>
<body class="layui-main" style="width: 100%;">
<input type="hidden" value="${positionType}" id="positionType">
	<blockquote class="layui-elem-quote">目标管理</blockquote>
		<form id="createMsgForm" name="createMsgForm" class="layui-form"
			action="">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<select name="proGroupNo" id="proGroupNo"
							lay-filter="proGroupSelect" style="width: 210;">
								<c:forEach items="${groupList}" var="group">
									<option value="${group.proGroupNo}">${group.proGroupName}</option>
								</c:forEach>
						</select>
					</div>
					<div class="layui-inline">
						<select name="proTeamNo" id="proTeamNo" style="width: 210;">
							<c:if test="${positionType=='70'}">
								  <c:forEach items="${teanList}" var="tean">
									<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
								  </c:forEach>
							</c:if>
							<c:if test="${positionType!='70'}">
							<option value="">项目组名称</option>
							<option value="">全部</option>
							<c:forEach items="${teanList}" var="tean">
								<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
							</c:forEach>
							</c:if>
						</select>
					</div>
					 <div class="layui-inline">
		      <label class="layui-form-label">月份 </label>
					<div id="datePicker1" class="layui-input-inline">
			                <input type="text" id="months" name="months" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
		                   </div>
		</div>
					<div class="layui-inline">
						<button class="layui-btn" type="button" data-method="doSearchSum" id="doSearchSum" >查询</button>
						<button class="layui-btn" type="button" onclick="addgoal();">添加目标</button>
					</div>
				</div>
			</div>
			<div class="layui-form-item" id="dateDiv">
				<div class="layui-inline">
					<table class="layui-table" lay-even="" lay-skin="line"
						style="text-align: center;width: 100%;">
						<colgroup align="center">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
						</colgroup>
						<thead>
							<tr>
								<th>项目组</th>
								<th>月份</th>
								<th>目标</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="detailDiv">

						</tbody>
						<script id="tplSrc" type="text/html">
							 {{#  layui.each(d.body, function(index, x){}}
							     <tr align="left">
                                    <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
									<td>{{x.months==undefined?'':x.months}}</td>
                                    <td>{{x.goal==undefined?'':x.goal}}</td>
								    <td><button  class="layui-btn" type="button" onclick="deleteInfor('{{x.rouid}}','{{x.months}}','{{x.proTeamNo}}')">删除</button></td>
								 </tr>
							{{#  }); }} 
					   </script>

					</table>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<div id="laypageDiv"></div>
				</div>
			</div><button style="margin: 0px;"></button>
		</form>
	</div>
	<input id="totalNum" type="hidden" name="totalNum" >
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
	var msg = new msgTool();
	layui.use([ 'form', 'layer', 'laytpl', 'laypage', 'laydate' ],
	function() {
	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
						var form = layui.form(), layer = layui.layer, laypage = layui.laypage, laytpl = layui.laytpl;
						var active = {
							doSearchSum : function() { //搜索
								var getTpl = tplSrc.innerHTML;
								var dataObj = {
									"proGroupNo" : $("#proGroupNo").val(),
									"proTeamNo" : $("#proTeamNo").val(),
									"months": $("#months").val(),
								}
								msg.sendMsg("/page/main/goal.do",
									dataObj,function(data) {
										laytpl(getTpl).render(data,function(html) {
											detailDiv.innerHTML = html;
										});
										
								});
							}
						}
						
	$('.layui-btn').on('click',function() {
		var othis = $(this), method = othis.data('method');
		active[method] ? active[method].call(this,othis) : '';
	});
});
	 function flush(){
	        $('#doSearchSum').click();
	    }

 
	 function addgoal(){
		 
	        layer.open({
	            type: 2,
	            title:"新增目标",
	            area: ['70%', '80%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/addgoal.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	 
	 }
	 
 
	 function deleteInfor(rouid,months,proTeamNo) {
		 var jsonDate = {};
	        jsonDate.rouid = rouid;
	        jsonDate.months = months;
	        jsonDate.proTeamNo = proTeamNo;
		        msg.sendMsg("/page/need/dodeletegoal.do", jsonDate, function (data) {
		        	 layer.alert("删除成功！", function () {
		        		   location.reload();
		                });
		        });
	    }
	 

	 

	 
	 
	 
	 
	 
	 

	 
	 
</script>

</html>